import java.util.*;
class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode(int x) { val = x; }
 }

/**
 * leetcode开幕式烟花，二叉树计算val的种类数量
 */
public class Solution {
    private Set<Integer> set = new HashSet<>();
    private int count = 0;
    public int numColor(TreeNode root) {
        if(root == null) {
            return 0;
        }
        if(!set.contains(root.val)) {
            count++;
            set.add(root.val);
        }
        numColor(root.left);
        numColor(root.right);
        return count;
    }
}